# print(84.5/2)

# print(130*2)

# print(154*0.13)

# import keyword

# print(keyword.kwlist)

# print(r"this is a line with \n")

# print("this is a line with \n")

# print(u"this is a line with \n")

# print("this " "is " "string")

# str = '0123456789'

# print('-------------------------------\n'+str)
# print(str[0:4:3]*2)

# input("这是一个简单的input信息")
# x=int(input("请输入X的值："))
# print(int(x))
# print(type(x))
# import sys
# import sys; x = 'W3Cschool'; sys.stdout.write(x + '\n')

# print ('命令行参数为:')
# for i in sys.argv:
#     print (i)
# print ('\n python 路径为',sys.path)

# import random

# print(random.choice(range(103)))
# print("\a")

# edibles = ["ham", "spam","eggs","nuts"]
# for food in edibles:
#     if food == "nuts":
#         print("No more spam please!")
#         break
#     print("Great, delicious " + food)
# else:
#     print("I am so glad: No spam!")
# print("Finally, I finished stuffing myself")

# number = 7
# guess = -1
# print("猜数字!")
# while guess != number:
#     guess = int(input("请输入你要猜的数字"))
#     if guess == number:
#         print("你猜中了，真厉害！")
#     elif guess < number:
#         print("猜小了，再猜猜？")
#     elif guess > number:
#         print("猜大了，在猜猜？")

# import sys

# def fibonacci(n): # 生成器函数 - 斐波那契   a=0 b=1,a=1,b=1,a=1,b=2
#     a, b, counter = 0, 1, 0
#     while True:
#         if (counter > n): 
#             return
#         yield a
#         a, b = b, a + b
#         counter += 1
# f = fibonacci(10) # f 是一个迭代器，由生成器返回生成

# while True:
#     try:
#         print (next(f), end=" ")
#     except StopIteration:
#         sys.exit()

# matrix = [
#      [1, 2, 3, 4],
#      [5, 6, 7, 8],
#      [9, 10, 11, 12],

#  ]
# print([[row[i] for row in matrix] for i in range(4)])

# vec1 = [2, 4, 6]
# vec2 = [4, 3, -9]
# print([[x*y for x in vec1] for y in vec2])

# vec1 = [2, 4, 6]
# vec2 = [4, 3, -9,0]
# for q, a in zip(vec1, vec2):
#   print(a)
#   print('What is your {0}?  It is {1}.'.format(q, a))

#使用pickle模块将数据对象保存到文件

# import pickle ,pprint

# data1 = {'a': [1, 2.0, 3, 4+6j],
#          'b': ('string', u'Unicode string'),
#          'c': None}

# selfref_list = [1, 2, 3]
# selfref_list.append(selfref_list)

# output = open('data.pkl', 'wb')

# # Pickle dictionary using protocol 0.
# pickle.dump(data1, output)

# # # Pickle the list using the highest protocol available.
# pickle.dump(selfref_list, output, -1)

# output.close()

# pkl_file = open('data.pkl', 'rb')

# data1 = pickle.load(pkl_file)
# print(data1)
# pprint.pprint(data1)

# # data2 = pickle.load(pkl_file)
# # pprint.pprint(data2)
# # 按顺序读
# line = pkl_file.readlines()
# print ("读取的数据为: %s" % (line))

# pkl_file.close()


# import sys

# try:
#     f = open('myfile.txt')
#     s = f.readline()
#     i = int(s.strip())
# except OSError as err:
#     print("OS error: {0}".format(err))
# except ValueError:
#     print("Could not convert data to an integer.")
# except:
#     print("Unexpected error:", sys.exc_info()[0])
#     raise

# lst = ["张无忌","张大海","张单身","大冬冬"]
# tem = []
# for item in lst:
#     if item.startswith("张"):
#         tem.append(item)
#         #lst.remove(item)
# for item in tem:
#     lst.remove(item)

# print(lst)

# def fn(num):
#     result = [0,1]
#     for i in range(2,num):
#         print(i)
#         result.append(result[i-1]+result[i-2])
#         print(result[i-1],result[i-2])
#     return result
# print(fn(5))

# 20个学生,成绩在60~100直接,筛选90分以上的同学
# import random
# students = {'student'+ str(i) : random.randint(60,100) for i in range(1,21)}
# print(students)
# print({name: value for name,value in students.items() if value > 90})

# str = '12KG'
# json = {"name":"张三","age":20,"city":"北京"}

# print(str[-2:],str[-1:],str[0:-2],json.values())
# print('{:^^20,.2f}'.format(126789.12389))   
# print([c for c in str])
# print([c for c in str if c.isdigit()])
# tup = ('a',1)
# print(str[:-1])

# print(dir(tup))

# 算法基础库numpy
import numpy as np
# # 创建一个一维数组
# arr1 = np.array([1, 2, 3, 4, 5,6])
# # 升维
# # print(arr1.reshape(3, 2))
# # 创建一个3*3数组
# arr2 = np.arange(9).reshape(3, 3)
# print(arr2)
# print(arr2[:2,1:])

# 创建一个pandas series
import pandas as pd
# ser1 = pd.Series([1, 2, 3, 4, 5])
# print(ser1)
# ser2 = pd.Series({'a': 1, 'b': 2, 'c': 3},index=['b', 'c', 'd'])
# print(ser2)
# ser2.name = 'adfa'
# ser2['name'] = 'adfa'
# print(ser2)
# ser2.index.name = '6'
# print(ser2)

# 创建一个字典 DataFrame
data = {'name': ['张三', '李四', '王五'],
    'age': [20, 25, 30],
    'gender': ['男', '女', '男']}
df = pd.DataFrame(data)
# 修改index 
# df.index = ['name', 'age', 'gender']
arr = df['age'] <  25

print(arr)
print(df.loc[arr])
# # 创建一个数组 DataFrame
# df1 = {'age': np.arange(3)}
# df2 = {'name': df['name'][:-1]}
# df3 = {'name': df['name'][:]}
# df4 = pd.DataFrame(df1)
# # print(df1,df2,df3)
# print(df4)
# print(df4.loc[1])
# print(df4.columns[0])
# # r = 5+'5' #报错

#读取xl数据
# import xlrd
# workbook = xlrd.open_workbook('./file/012.爬取数据.xlsx')
# sheet = workbook.sheet_by_index(0)
# for row in sheet.get_rows():
#     for cell in row:
#         print(cell.value,end=',')
#     print(row[:-1].value)